package com.example.demo.entity;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "统一返回格式")
public class ResponseResult {
    private Integer code;
    private String msg;
    private Object data;

    public static ResponseResult ok(){
        return new ResponseResult(200,"请求成功",null);
    }

    public static ResponseResult ok(Object data){
        return new ResponseResult(200,"请求成功",data);
    }

    public static ResponseResult ok(String msg){
        return new ResponseResult(200,msg,null);
    }

    public static ResponseResult ok(String msg,Object data){
        return new ResponseResult(200,msg,data);
    }

    public static ResponseResult fail(){
        return new ResponseResult(500,"请求失败",null);
    }

    public static ResponseResult fail(Object data){
        return new ResponseResult(500,"请求成功",data);
    }

    public static ResponseResult fail(String msg){
        return new ResponseResult(500,msg,null);
    }

    public static ResponseResult fail(String msg,Object data){
        return new ResponseResult(500,msg,data);
    }


}
